<?php 
ini_set("display_errors",1); 

?>
<script type="text/javascript" src="./../js/jquery.js"></script> 
<script type="text/javascript" src="./../js/jquery.json-2.2.min.js"></script> 

<script type="text/javascript" src="./../js/highlight.pack.js"></script>            
<link rel="stylesheet" href="./../css/hlcode/default-dark.css" type="text/css"> 
<script type="text/javascript">
	$(document).ready(function(){
 
		$("#hid1").val($("#text1").val());
		$("#hid2").val($("#text2").val());

		$("#text1").replaceWith('<pre id="pre" style="margin:0px;width:400px;"><code class="php">'+$("#hid1").val()+'</code></pre>');
		$("#text2").replaceWith('<pre id="pre2" style="margin:0px;"><code class="c">'+$("#hid2").val()+'</code></pre>');

		$("#pre").live('click', function() {
			$("#pre").replaceWith('<textarea style="width:400px;height:500px;font-size:13px;" name="text1" id="text1">'+$("#hid1").val()+'</textarea></pre>');
			$("#text1").focus();
		}); 

		$("#text1").live('blur', function() {
			$("#hid1").val($("#text1").val());
		}); 

		$("#submit").click(function() {
		var code = $("#hid1").val();
			$.ajax({
				type: "POST", 
				url: "generate.php", 
				data: "code="+$.toJSON(code),
				success: function(data){
        			document.location.href="http://deeflow.com/parser/index.php";
				}
      		});
		});
		$("#example").click(function() {
			$.ajax({
				type: "POST", 
				url: "generate.php", 
				data: "dump=1",
				success: function(data){
        			document.location.href="http://deeflow.com/parser/index.php";
				}
      		});
		});
	});
</script>
<div style="width:1000px; margin: 0px auto;">
	<table style="table-layout:fixed;">
		<tr>
			<td valign="top">
		<form method="post">
		<textarea style="width:400px;height:500px;font-size:13px;" name="text1" id="text1"><?php if(count($_POST)) print $_POST['text1']; else print file_get_contents('./class.php.sample');?></textarea>
		<input type="button" value="ПроDROIDить код" id="submit"><br/>
		<input type="button" value="Живой пример" id="example"></div>
		</form>
	 		</td>
			<td>
		<textarea style="width:600px; height:540px;" wrap="off" id="text2"><?php print file_get_contents('./c/droid.c');?></textarea>
			</td>
		</tr>
	</table>
	<textarea style="display:none;" id="hid1"></textarea>
	<textarea style="display:none;" id="hid2"></textarea>
 
<script>hljs.initHighlightingOnLoad(false);</script> 
